// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

const db = cloud.database({
  env: 'gtss-2b1812'
})
exports.main = async(event, context) => {
  try {
    if (event.type == 'stu') {
      await db.collection('Student').doc(event.id).remove()
    }
    if (event.type == 'tea') {
      await db.collection('Teacher').doc(event.id).remove()
    }
    return {
      result: 1
    }
  } catch (e) {
    return {
      result: 0
    }
  }
}